﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClassLibrary.DAO;

namespace mprsc
{
    public partial class JobListNonWarranty : Form
    {
        TblJobsDAO jobDAO = new TblJobsDAO(Global.CONNECTION_STRING);
        int dem;
        int demApproval;
        int dempickup;

        public JobListNonWarranty()
        {
            InitializeComponent();
        }

        private void JobListNonWarranty_Load(object sender, EventArgs e)
        {
            this.CenterToScreen();
            loadJobList();
            LoadCustomerApproval();
            loadcustomerpickup();
            txtdem.Text = Convert.ToString(dem);
            txtDemApproval.Text = Convert.ToString(demApproval);
            txtDemPickup.Text = Convert.ToString(dempickup);
        }
        // load List Job
        private void loadJobList()
        {
            try
            {
                grdJobList.DataSource = jobDAO.GetJobNonWarranty(1, 1);
                dem += Convert.ToInt32(grdJobList.Rows.Count); 
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        private void LoadCustomerApproval()
        {
            grdCustomerApproval.DataSource = jobDAO.GetJobNonWarranty(2, 1);
            demApproval = Convert.ToInt32(grdCustomerApproval.Rows.Count);
        }
        private void loadcustomerpickup()
        {
            grdpickup.DataSource = jobDAO.GetJobNonWarranty(3, 1);
            dempickup = Convert.ToInt32(grdpickup.Rows.Count);
        }

        private void btnDetail_Click(object sender, EventArgs e)
        {
            string idJob = grdJobList.CurrentRow.Cells["JobID"].Value.ToString();
            NewBooking newBooking = new NewBooking();
            newBooking.Sender1(idJob);
            this.Hide();
            newBooking.Show();
        }

        private void btnDetailApproval_Click(object sender, EventArgs e)
        {
            string idJob = grdCustomerApproval.CurrentRow.Cells["IDJob"].Value.ToString();
            NewBooking newBooking = new NewBooking();
            newBooking.Sender1(idJob);
            this.Hide();
            newBooking.Show();
        }
    }
}
